package com.mes.bac.backend.controller;

import com.mes.bac.backend.common.vo.R;
import com.mes.bac.backend.entity.Wkproc;
import com.mes.bac.backend.service.IWkprocService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@Tag(name = "工序管理", description = "用于管理工序基础信息")
@RestController
@RequestMapping("/api/wkproc")
public class WkprocController {

    @Autowired
    private IWkprocService wkprocService;

    @Operation(summary = "新增或更新工序")
    @PostMapping("/save")
    public R<Boolean> save(@RequestBody Wkproc wkproc) {
        return R.success(wkprocService.saveOrUpdate(wkproc));
    }

    @Operation(summary = "根据ID删除工序")
    @DeleteMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id) {
        return R.success(wkprocService.removeById(id));
    }

    @Operation(summary = "查询所有工序")
    @GetMapping("/list")
    public R<List<Wkproc>> list() {
        return R.success(wkprocService.list());
    }
}